import { http } from "@/utils/http";
type Result = {
  success: boolean;
  data?: Array<any>;
};

type ResultTable = {
  errCode: number;
  errMsg: string;
  errDlt: string;
  data?: {
    /** 列表数据 */
    users: Array<any>;
    /** 总条目数 */
    total?: number;
    /** 每页显示条目个数 */
    pageSize?: number;
    /** 当前页数 */
    currentPage?: number;
  };
};

type RequestParams = {
  current: number;
  pageSize: number;
  keyword?: string;
  normal?: number;
  pagination: {
    pageNumber: number;
    showNumber: number;
  };
};

/** 业务系统-用户管理列表 */
export const getUserList = (data: RequestParams) => {
  return http.request<ResultTable>("post", "/chat/user/search/full", {
    data
  });
};

/** 业务系统-用户管理封禁列表 */
export const getBlockList = (data: RequestParams) => {
  return http.request<ResultTable>("post", "/im/block/search", {
    data
  });
};

/** 业务系统-用户管理创建新用户 */
export const createUser = (data: any) => {
  return http.request<ResultTable>("post", "/im/user/import/json", {
    data
  });
};

/** 业务系统-用户管理修改用户 */
export const updateUser = (data: any) => {
  return http.request<ResultTable>("post", "/chat/user/update", {
    data
  });
};

/** 业务系统-用户管理禁用用户 */
export const addBlock = (data: any) => {
  return http.request<ResultTable>("post", "/im/block/add", {
    data
  });
};

/** 业务系统-用户管理重置密码 */
export const resetPw = (data: any) => {
  return http.request<ResultTable>("post", "/im/user/password/reset", {
    data
  });
};

/** 业务系统-用户管理解禁用户 */
export const delBlock = (data: any) => {
  return http.request<ResultTable>("post", "/im/block/del", {
    data
  });
};

/** 业务系统-注册管理获取默认好友*/
export const getDefaultFriend = (data: any) => {
  return http.request<ResultTable>("post", "/im/default/user/search", {
    data
  });
};

/** 业务系统-注册管理新增好友*/
export const addDefaultFriend = (data: any) => {
  return http.request<ResultTable>("post", "/im/default/user/add", {
    data
  });
};

/** 业务系统-注册管理移除好友*/
export const delDefaultFriend = (data: any) => {
  return http.request<ResultTable>("post", "/im/default/user/del", {
    data
  });
};

/** 业务系统-注册管理获取默认群组*/
export const getDefaultGroup = (data: any) => {
  return http.request<ResultTable>("post", "/im/default/group/search", {
    data
  });
};

/** 业务系统-注册管理新增群组*/
export const addDefaultGroup = (data: any) => {
  return http.request<ResultTable>("post", "/im/default/group/add", {
    data
  });
};

/** 业务系统-注册管理移除群组*/
export const delDefaultGroup = (data: any) => {
  return http.request<ResultTable>("post", "/im/default/group/del", {
    data
  });
};

/** 系统管理-用户管理-获取所有角色列表 */
export const getAllRoleList = () => {
  return http.request<Result>("get", "/list-all-role");
};

/** 系统管理-用户管理-根据userId，获取对应角色id列表（userId：用户id） */
export const getRoleIds = (data?: object) => {
  return http.request<Result>("post", "/list-role-ids", { data });
};

/** 业务系统-角色管理列表 */
export const getRoleList = (data?: object) => {
  return http.request<ResultTable>("post", "/role", { data });
};

/** 业务系统-菜单管理列表 */
export const getMenuList = (data?: object) => {
  return http.request<Result>("post", "/menu", { data });
};

/** 业务系统-部门管理列表 */
export const getDeptList = (data?: object) => {
  return http.request<Result>("post", "/dept", { data });
};

/** 获取系统监控-在线用户列表 */
export const getOnlineLogsList = (data?: object) => {
  return http.request<ResultTable>("post", "/online-logs", { data });
};

/** 获取系统监控-登录日志列表 */
export const getLoginLogsList = (data?: object) => {
  return http.request<ResultTable>("post", "/login-logs", { data });
};

/** 获取系统监控-操作日志列表 */
export const getOperationLogsList = (data?: object) => {
  return http.request<ResultTable>("post", "/operation-logs", { data });
};

/** 获取系统监控-系统日志列表 */
export const getSystemLogsList = (data?: object) => {
  return http.request<ResultTable>("post", "/system-logs", { data });
};

/** 获取系统监控-系统日志-根据 id 查日志详情 */
export const getSystemLogsDetail = (data?: object) => {
  return http.request<Result>("post", "/system-logs-detail", { data });
};

/** 获取角色管理-权限-菜单权限 */
export const getRoleMenu = (data?: object) => {
  return http.request<Result>("post", "/role-menu", { data });
};

/** 获取角色管理-权限-菜单权限-根据角色 id 查对应菜单 */
export const getRoleMenuIds = (data?: object) => {
  return http.request<Result>("post", "/role-menu-ids", { data });
};
